/**
 * Created by zhu on 2016/2/11.
 */
$(function(){
    var myhregf = window.location.href;
    var count = myhregf.split('/').length;
    var id = myhregf.split('/')[count-1];

    $.get(contextPath+"/mmt_admin/seller/"+id,function(data){
        initSeller(data);
    });
    $.get(contextPath+"/mmt_admin/seller/goods/"+id,function(data){
        initGoods(data);
    })

});

function initSeller(data){
    data = $.parseJSON(data);
    if(data.status == 0){
        $('#shopName').text(data.bean.shopName);
    }else{
        alert("加载卖家信息失败")
    }
}

function initGoods(data){
    data = $.parseJSON(data);
    if(data.status == 0){
        var goods = $('#goods');
        goods.empty();
        $.each(data.list,function(i,item){
            var temp = ' <div align="center" class="col-md-3"><img src="'+contextPath+item.index_url+'" style="height: 140px;width: 140px" class="img-thumbnail">' +
                '<p align="center" style="margin-top: 10px;font-size: 18px;">'+item.name+'</p>' +
                '<p style="padding-bottom:30px;">ID:'+item.id+'</p>' +
                '</div>';
            goods.append(temp);
        })
    }else{
        alert("加载商品信息失败")
    }
}